package intranet.client;
/**
 * @author Baptiste RENDU
 */
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TabLayoutPanel;


public class Tabs extends TabLayoutPanel{
	ViewerTab viewer;
	/**
	 * Construit une fenetre a onglets
	 * @param la hauteur et l'unité de mesure de l'onglet
	 */
	public Tabs(double barHeight, Unit barUnit) {
		super(barHeight, barUnit);
		viewer=new ViewerTab();
		add(viewer,"viewer");
		addSelectionHandler(new SelectionHandler<Integer>() {
			
			@Override
			public void onSelection(SelectionEvent<Integer> event) {
				// TODO Auto-generated method stub
				if(((Tabs)event.getSource()).getSelectedIndex()==0)
				{
					((Tabs)event.getSource()).getViewerTab().onResize();
				}
			}
		});
		
	}
	/**
	 * retourne le contenu de l'onglet viewer
	 * @return un objet de type ViewerTab
	 */
	public ViewerTab getViewerTab()
	{
		return viewer;
	}
	public void setSize(int width, int height)
	{
		setHeight(height+"px");
		setWidth((width-20)+"px");

		for(int i=0;i<this.getWidgetCount();i++)
		{
			this.getWidget(i).setSize(width-50+"px", height-50+"px");
		}
	}
}
